home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / cujoct93.zip / 1110065A < prev    next >
Text File  |  1993-07-14  |  619b  |  31 lines

  1. // just a mechanism for self deleting
  2. // strings which can be hacked
  3. class TempString
  4. {
  5. private:
  6.   char *str;
  7. public:
  8.   // create a TempString from a char *
  9.   TempString(const char *s)    
  10.   {
  11.     str= new char[strlen(s) + 1];
  12.     strcpy(str, s);
  13.   }
  14.  
  15.   // create a TempString from a substring of char *  
  16.   TempString(const char *s, int len)    
  17.   {
  18.     str= new char[len + 1];
  19.     if(len) strncpy(str, s, len);
  20.     str[len]= '\0';
  21.   }
  22.  
  23.   // remove storage when done
  24.   ~TempString(){ delete [] str; }
  25.  
  26.   // convert a TempString into a char *
  27.   operator char*() const { return str; }
  28. };
  29.  
  30.  
  31.